<%@ page import="com.Bean.Ticket" %>
<%@ page import="com.Bean.User" %>
<%@ page import="com.Util.DB" %>
<%@ page import="com.Util.TkDao" %>
<%@ page import="com.Util.UserDao" %>
<%@ page import="java.util.Set" %><%--
  Created by IntelliJ IDEA.
  User: root
  Date: 19-6-23
  Time: 下午8:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    boolean istest = DB.jsptest;

    String tkid=new String();
    String username=new String();
    User user=new User();
    if(istest)
    {
        username=request.getParameter("u");

    }else if (session.getAttribute("username") == null) {

        response.sendRedirect("../login.jsp");
        //request.getRequestDispatcher("../login.jsp").forward(request, response);
    }else{
        username=session.getAttribute("username").toString();
    }
    user= UserDao.selectUser(username);
%>
<html>
<head>
    <title>Tickets内容</title>
    <link rel="stylesheet" href="../css/services.css">
    <script src="../js/scripts.minf5b501.js"></script>
</head>
<body>
<section id="header">
    <div class="container">
        <ul class="top-nav">
            <li class="primary-action">
                <a href="../logout" class="btn">
                    注销
                </a>
            </li>
        </ul>
    </div>
</section>
<section>
    <nav id="nav" class="navbar navbar-default navbar-main" role="navigation">
        <div class="container">

            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#primary-nav">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>

            <div class="collapse navbar-collapse" id="primary-nav">
                <ul class="nav navbar-nav">
                    <li menuitemname="Home" class="" id="Primary_Navbar-Home">
                        <a href="../index.html">
                            主页
                        </a>
                    </li>

                    <li menuitemname="Services" class="dropdown" id="Primary_Navbar-Services">
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            服务
                            &nbsp;<b class="caret"></b> </a>
                        <ul class="dropdown-menu">
                            <li menuitemname="pm-addon-overview" id="Primary_Navbar-Services-pm-addon-overview">
                                <a href="./myvps.jsp">
                                    我的vps
                                </a>
                            </li>
                            <li menuitemname="My Services" id="Primary_Navbar-Services-My_Services">
                                <a href="./tickets.jsp">
                                    服务咨询
                                </a>
                            </li>
                            <li menuitemname="My Services">
                                <a href="./openticket.jsp">
                                    咨询客服
                                </a>
                            </li>

                        </ul>
                    </li>

                    <li menuitemname="Home" class="" id="Primary_Navbar-Home">
                        <a href="./ordervps.jsp">
                            购买VPS
                        </a>
                    </li>

                </ul>
            </div>
        </div>
    </nav>
</section>
<section id="main-body">
<div class="container">
    <div class="row">
        <div class="col-md-9 pull-md-right">

            <div class="header-lined">
                <h1>服务咨询
                    <small>您的咨询记录</small>
                </h1>
                <ol class="breadcrumb">
                    <li>
                        <a href="/index.html"> 主页
                        </a></li>
                    <li>
                        <a href="#"> 服务
                        </a></li>
                    <li class="active">
                        服务咨询
                    </li>
                </ol>
            </div>

        </div>
        <div class="col-md-3 pull-md-left sidebar">
            <div menuitemname="Client Details" class="panel panel-sidebar panel-sidebar">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        <i class="fas fa-user"></i>&nbsp; 我的信息
                        <i class="fas fa-chevron-up panel-minimise pull-right"></i>
                    </h3>
                </div>

                <div class="panel-body">
                    <strong><%=user.getUsername()%></strong><br>
                    <%=user.getEmail()%><br>
                    <%=user.getFamilyname()%> <%=user.getName()%><br>
                </div>
                <div class="panel-footer clearfix">
                </div>
            </div>
        </div>
        <div class="col-md-9 pull-md-right main-content">
            <link rel="stylesheet" type="text/css" href="../css/dataTables.bootstrap.css">
            <link rel="stylesheet" type="text/css" href="../css/dataTables.responsive.css">
            <script type="text/javascript" charset="utf8" src="../js/jquery.dataTables.min.js"></script>
            <script type="text/javascript" charset="utf8" src="../js/dataTables.bootstrap.min.js"></script>
            <script type="text/javascript" charset="utf8" src="../js/dataTables.responsive.min.js"></script>
            <script type="text/javascript">

                if (typeof (buildFilterRegex) !== "function") {
                    function buildFilterRegex(filterValue) {

                        if (filterValue.indexOf('&') === -1) {
                            return '[~>]\\s*' + jQuery.fn.dataTable.util.escapeRegex(filterValue) + '\\s*[<~]';
                        } else {
                            var tempDiv = document.createElement('div');
                            tempDiv.innerHTML = filterValue;

                            return '\\s*' + jQuery.fn.dataTable.util.escapeRegex(tempDiv.innerText) + '\\s*';
                        }
                    }
                }
                jQuery(document).ready(function () {
                    jQuery(".view-filter-btns a").click(function (e) {
                        var filterValue = jQuery(this).find("span").not('.badge').html().trim();
                        var dataTable = jQuery('#tableTicketsList').DataTable();
                        var filterValueRegex;
                        if (jQuery(this).hasClass('active')) {
                            jQuery(this).removeClass('active');
                            jQuery(this).find("i.far.fa-dot-circle").removeClass('fa-dot-circle').addClass('fa-circle');
                            dataTable.column(2).search('').draw();
                        } else {
                            jQuery('.view-filter-btns .list-group-item').removeClass('active');
                            jQuery('i.far.fa-dot-circle').removeClass('fa-dot-circle').addClass('fa-circle');
                            jQuery(this).addClass('active');
                            jQuery(this).find(jQuery("i.far.fa-circle")).removeClass('fa-circle').addClass('fa-dot-circle');
                            filterValueRegex = buildFilterRegex(filterValue);
                            dataTable.column(2)
                                .search(filterValueRegex, true, false, false)
                                .draw();
                        }

                        // Prevent jumping to the top of the page
                        // when no matching tag is found.
                        e.preventDefault();
                    });
                });
            </script>
            <script type="text/javascript">
                var alreadyReady = false; // The ready function is being called twice on page load.
                jQuery(document).ready(function () {
                    var table = jQuery("#tableTicketsList").DataTable({
                        "dom": '<"listtable"fit>pl', "responsive": true,
                        "oLanguage": {
                            "sEmptyTable": "No Records Found",
                            "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
                            "sInfoEmpty": "Showing 0 to 0 of 0 entries",
                            "sInfoFiltered": "(filtered from _MAX_ total entries)",
                            "sInfoPostFix": "",
                            "sInfoThousands": ",",
                            "sLengthMenu": "Show _MENU_ entries",
                            "sLoadingRecords": "Loading...",
                            "sProcessing": "Processing...",
                            "sSearch": "",
                            "sZeroRecords": "No Records Found",
                            "oPaginate": {
                                "sFirst": "First",
                                "sLast": "Last",
                                "sNext": "Next",
                                "sPrevious": "Previous"
                            }
                        },
                        "pageLength": 10,
                        "order": [
                            [0, "asc"]
                        ],
                        "lengthMenu": [
                            [10, 25, 50, -1],
                            [10, 25, 50, "All"]
                        ],
                        "aoColumnDefs": [
                            {
                                "bSortable": false,
                                "aTargets": []
                            },
                            {
                                "sType": "string",
                                "aTargets": [2]
                            }
                        ],
                        "stateSave": true
                    });

                    // highlight remembered filter on page re-load
                    var rememberedFilterTerm = table.state().columns[2].search.search;
                    if (rememberedFilterTerm && !alreadyReady) {
                        // This should only run on the first "ready" event.
                        jQuery(".view-filter-btns a span").each(function (index) {
                            if (buildFilterRegex(jQuery(this).text().trim()) == rememberedFilterTerm) {
                                jQuery(this).parent('a').addClass('active');
                                jQuery(this).parent('a').find('i').removeClass('fa-circle').addClass('fa-dot-circle');
                            }
                        });
                    }
                    alreadyReady = true;
                });
            </script>
            <script type="text/javascript">
                jQuery(document).ready(function () {
                    var table = jQuery('#tableTicketsList').removeClass('hidden').DataTable();
                    table.order(3, 'desc');
                    table.draw();
                    jQuery('#tableLoading').addClass('hidden');
                });
            </script>
            <script>
                $(document).ready(function () {
                    $(".username").change(function () {
                        var uname = $(this).val();
                        $.ajax({
                            type: "POST",
                            url: "./postsearchtickets.jsp",
                            data: "username=" + uname,
                            success: function (msg) {
                                var a = "<font color=red><b>" + msg + "</b>"
                                $(".status").html(a);
                            }
                        });
                    });
                });
            </script>
            <div class="table-container clearfix">
                <div id="tableTicketsList_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                    <div class="listtable">
                        <table id="tableTicketsList" class="table table-list dataTable no-footer dtr-inline"
                               aria-describedby="tableTicketsList_info" role="grid" style="width: 0px;">
                            <thead>
                            <tr role="row">
                                <th class="sorting" tabindex="0" aria-controls="tableTicketsList" rowspan="1" colspan="1"
                                    style="width: 0px;" aria-label="Department: activate to sort column ascending">
                                    类型
                                </th>
                                <th class="sorting" tabindex="0" aria-controls="tableTicketsList" rowspan="1" colspan="1"
                                    style="width: 0px;" aria-label="Subject: activate to sort column ascending">主题
                                </th>
                                <th class="sorting" tabindex="0" aria-controls="tableTicketsList" rowspan="1" colspan="1"
                                    style="width: 0px;" aria-label="Status: activate to sort column ascending">状态
                                </th>
                                <th class="sorting_desc" tabindex="0" aria-controls="tableTicketsList" rowspan="1"
                                    colspan="1" style="width: 0px;"
                                    aria-label="Last Updated: activate to sort column ascending" aria-sort="descending">Last
                                    上次回复
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                                <%
                            Set<Ticket> tkSet= TkDao.selectTkbyUsername(username);

                            for(Ticket tk:tkSet)
                                {
                        %>
                            <tr onclick="window.location='viewticket.php?tid=574300&amp;c=KnwNT1hy'" role="row" class="odd">
                                <td tabindex="0">
                                    <%=tk.getTypes()%>
                                </td>
                                <td>
                                    <a href="message.jsp?tkid=<%=tk.getId()%>" class="border-left">
                                        <span class="ticket-number">#<%=tk.getId()%></span>
                                        <span class="ticket-subject"><%=tk.getSubject()%></span>
                                    </a>
                                </td>
                                <td>
                                <span class="label status status-<%=tk.getStatus()%>"
                                      style="margin: auto;width: 100px;"><%=tk.getStatus()%></span>
                                </td>
                                <td class="text-center sorting_1">
                                    <%=tk.getLastupdate()%>
                                </td>
                            </tr>
                                <%
                            }
                        %>

                        </table>
                    </div>
                </div>
            </div>
        <div class="clearfix"></div>
    </div>
</div>

</section>
</body>
</html>
